package com.lsm.sm.entity;

/**
 * Net entity. @author MyEclipse Persistence Tools
 */

public class Net extends Model {
	private static final long serialVersionUID = 3419527908053604593L;
	private String account;
	private String name;
	private String description;
	private Integer parent;
	private Net preNet;
	
	// Constructors

	/** default constructor */
	public Net() {}
	
	public Net( String name ){
		this.name = name;
	}

	public String getAccount() {
		return this.account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getParent() {
		return parent;
	}

	public void setParent(Integer parent) {
		this.parent = parent;
	}
	
	public void setParent( Net net ){
		setPreNet( net );
		this.parent = net.getId();
	}
	
	public Net getPreNet() {
		return preNet;
	}

	public void setPreNet(Net preNet) {
		this.preNet = preNet;
	}

	@Override
	public int hashCode() {
		return id;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Net other = (Net) obj;
		return id== other.id;
	}
	
	@Override
	public String toString() {
		return "Net [id=" + id + ", name=" + name + ", parent=" + parent
				+ ", preNet=" + preNet.getName() + "]";
	}
}